package midp;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public class DialogCanvas extends Canvas {

	// private int mCount, mMaximum;
	//private int mInterval;


	// , mX, mY, mRadius;
	private String message;

	private int frontColor = 8421631;//RGB 128, 128, 255

	// private boolean run = false;

	public DialogCanvas(String message) {
		this.message = message;


		// this.run = run;
		// // mCount = 0;
		// // mMaximum = 36;
		// mInterval = 100;
		//
		// //
		// // // Calculate the radius.
		// // int halfWidth = (mWidth - mRadius) / 2;
		// // int halfHeight = (mHeight - mRadius) / 2;
		// // mRadius = Math.min(halfWidth, halfHeight);
		// //
		// // // Calculate the location.
		// // mX = halfWidth - mRadius / 2;
		// // mY = halfHeight - mRadius / 2;
		//
		// // Create a Timer to update the display.
		// if (run) {
		// TimerTask task = new TimerTask() {
		// public void run() {
		// // mCount = (mCount + 1) % mMaximum;
		// repaint();
		// }
		// };
		// Timer timer = new Timer();
		//
		// timer.schedule(task, 0, mInterval);
		// }

	}


	public void paint(Graphics g) {
		int mWidth = getWidth();
		int mHeight = getHeight();

		// Clear the whole screen.
		//必须先清除前一屏幕的内容否则前后内容会叠加在一起
		g.setColor(255, 255, 255);
		g.fillRect(0, 0, mWidth, mHeight);


		//重新设置前台颜色
	    g.setColor(128, 128, 255);

	    System.out.println("color:"+g.getColor());

		// // Now draw the pinwheel.
		// g.drawArc(mX, mY, mRadius, mRadius, 0, 360);
		// g.fillArc(mX, mY, mRadius, mRadius, theta + 90, 90);
		// g.fillArc(mX, mY, mRadius, mRadius, theta + 270, 90);

		// Draw the message, if there is a message.
		if (message != null) {
			g.drawString(message, mWidth / 2, mHeight/2, Graphics.BOTTOM
					| Graphics.HCENTER);
		}
	}


	public String getMessage() {
		return message;
	}


	public void setMessage(String message) {
		this.message = message;
	}


	public int getFrontColor() {
		return frontColor;
	}


	public void setFrontColor(int frontColor) {
		this.frontColor = frontColor;
	}

}
